package com.baice.config;

import org.apache.catalina.LifecycleException;
import org.apache.catalina.startup.Tomcat;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;

@Component
public class SpringApplication implements WebServerFactory {

    // run() 方法中要求完成tomcat的创建及启动
    @Override
    public void run() throws ServletException, LifecycleException {
        Tomcat tomcat  =new Tomcat();
        tomcat.setPort(8080);
        // 创建应用上下文
        tomcat.addWebapp("/", "d://soft");
        tomcat.start();
        tomcat.getServer().await();
    }
}
